#include "app_ble_irq_handle.h"
#include "stm32_bluenrg_ble.h"
#include "hci.h"
#include "string.h"
#include "error.h"
/*private virable*/
extern SPI_HandleTypeDef SpiHandle;
volatile int16_t irq_flag = 0x00;
static uint8_t ble_tmp_buf[HCI_READ_PACKET_SIZE];
/*private function*/

void app_ble_irq_callback(void)
{
    Clear_SPI_EXTI_Flag();
    
    irq_flag = IRQ_BUSY;
    
}

void app_ble_irq_handle(void)
{
    while(BlueNRG_DataPresent()){
        app_ble_spi_read();
        Clear_SPI_EXTI_Flag();
    }        

}

void app_ble_spi_read(void)
{
     uint8_t data_len = 0;
     
     data_len = BlueNRG_SPI_Read_All(&SpiHandle, ble_tmp_buf, HCI_READ_PACKET_SIZE);
	
     if(data_len > 0){
        HCI_Event_CB(ble_tmp_buf);
     }

}
